﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="ListForums.aspx.cs" Inherits="Manage_ListForums" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
    <%
        if (Page.User.Identity.IsAuthenticated == false)
        {
            Response.Redirect("~/Manage/Default.aspx");
        }     
    %>
    <script type="text/javascript">
        function DeleteForum() {
            if (confirm('删除栏目将删除栏目下所有的文章。确认删除当前栏目吗？')) {
                return true;
            } else {
                return false;
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <asp:Literal ID="ErrorText" runat="server"></asp:Literal>
    <div style="margin:5px 0px 5px 0px">
        <asp:GridView ID="ForumView" runat="server" AllowPaging="True" 
            AutoGenerateColumns="False" BackColor="White" BorderColor="#CCCCCC" 
            BorderStyle="None" BorderWidth="1px" CellPadding="3" 
            DataSourceID="ForumDataSource">
            <Columns>
                <asp:TemplateField>
                    <ItemStyle Width="50px" HorizontalAlign="Center" />
                    <ItemTemplate>
                        <asp:LinkButton ID="DeleteButton" runat="server" Text="删除" CommandArgument='<%#Eval("ID") %>' OnClientClick="return DeleteForum();" OnCommand="Command_DeleteForum" />
                    </ItemTemplate>
                </asp:TemplateField>
                
                <asp:TemplateField HeaderText="栏目名称">
                    <ItemStyle Width="200px" />
                    <ItemTemplate>
                        <a href='./EditForum.aspx?fid=<%#Eval("ID") %>'><%#Eval("Name") %></a>
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:BoundField DataField="Description" HeaderText="栏目描述">
                <ItemStyle Width="200px" />
                </asp:BoundField>

                <asp:TemplateField HeaderText="父栏目名称">
                    <ItemStyle Width="150px" HorizontalAlign="Center" />
                    <ItemTemplate>
                        <%#Eval("Parent") == null ? "无" : Eval("Parent.Name")%>
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="文章数量">
                    <ItemStyle Width="80px" HorizontalAlign="Center" />
                    <ItemTemplate>
                        <asp:LinkButton ID="ViewButton" runat="server" OnCommand="Command_ViewArticles" CommandArgument='<%#Eval("ID") %>'><%#Eval("Articles") == null ? 0 : Eval("Articles.Count")%></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <FooterStyle BackColor="White" ForeColor="#000066" />
            <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
            <RowStyle ForeColor="#000066" />
            <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#F1F1F1" />
            <SortedAscendingHeaderStyle BackColor="#007DBB" />
            <SortedDescendingCellStyle BackColor="#CAC9C9" />
            <SortedDescendingHeaderStyle BackColor="#00547E" />
        </asp:GridView>
        <asp:LinqDataSource ID="ForumDataSource" runat="server" 
            ContextTypeName="TreasurerDataContext" EntityTypeName="" 
            Select="new (ID, Name, Description, Parent, Articles)" TableName="Forums">
        </asp:LinqDataSource>
    </div>

    
    <asp:LinkButton ID="NewForumButton" runat="server" Text="增加栏目" 
        onclick="NewForumButton_Click"  />
</asp:Content>

